using Z = Mint<998244353>;

void solve()
{
  int n;
  cin >> n;

  vector<Z> pw(n + 1);
  pw[0] = 1;

  vi a(n + 1), r(n + 1);
  rep(i, 1, n) {
    cin >> a[i];
    pw[i] = pw[i - 1] * 2;
  }

  rep(i, 1, n) {
    r[i] = min(i + 2, n + 1);
    while (r[i] <= n && a[r[i]] > a[r[i] - 1]) {
      r[i]++;
    }
  }

  vector<Z> f(n + 1);
  f[1] = 1;
  rep(i, 1, n) {
    vector<Z> S(n + 2);
    rep(j, i, n) {
      Z v = f[j] * pw[j - i];
      S[j] += v;
      S[r[j]] -= v;
    }
    rep(j, 1, n) {
      S[j] += S[j - 1];
      f[j] = S[j];
    }
  }

  cout << f[n];
}